package com.suixinsanren.design.state.demo.demo07;

public class SoldOutState implements State {

    private GumballMachine gumballMachine;

    public SoldOutState(GumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    @Override
    public void insertQuarter() {
        System.out.println("对不起，糖果已售罄，投币无效");
    }

    @Override
    public void ejectQuarter() {
        System.out.println("对不起，糖果已售罄，您还没有投入硬币");
    }

    @Override
    public void turnCrank() {
        System.out.println("对不起，糖果已售罄，无法开始游戏");
    }

    @Override
    public void refill(int numberGumball) {
        if (numberGumball > 0) {
            gumballMachine.refill(numberGumball);
            gumballMachine.setState(gumballMachine.getNoQuarterState());
        }
    }

    @Override
    public String toString() {
        return "糖果售罄状态";
    }
}
